﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MaterPage/Site.Master" AutoEventWireup="true" CodeBehind="Scorp_test.aspx.cs" Inherits="Js_Study.Pages.Scope.Scorp_test" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <input type="button" id="btn_1" value="Fun的参数传递--值类型作为参数" />
    <input type="button" id="btn_2" value="Fun的参数传递--引用类型作为参数" />
    <input type="button" id="btn_3" value="JS中没有块级作用域" />
    <script type="text/javascript">
        function addNum(num) {
            num++;
            return num;
        }
        var count = 10;

        $("#btn_1").click(function () {
            alert("addNum():" + addNum(count) + ",执行函数后的count值:" + count);
        });
        
        function setName(obj) {
            obj.name = "Nicholas";
            obj = new Object();
            obj.Name = "Damon";
        }

        $("#btn_2").click(function () {
            //var person = new Object({ name: 1, age: 12 });
            var person = new Object();
            setName(person);
            alert(person.name + ",我们可以把ECMAScript函数里的参数想象成局部变量!");
        });


        $("#btn_3").click(function () {
            //js 中没有块级作用域 所以在if 或者for中声明的变量，会直接属于当前执行环境中的变量
            if (true) {
                var color = "red";
            }

            for (var i = 0; i < 10; i++) {

            }
            alert(color + "--" + i);
        })
        
    </script>
</asp:Content>
